package CopaServer;

import Model.Entidades.Compra;
import Model.dao.CompraDAO;
import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class CompraBean implements ComprasRemote{
    
    @PersistenceContext(unitName="CompraEJBPU") //Compra Persistence Unit
    private EntityManager em;
    public Compra salvar(Compra c) throws Exception{
        CompraDAO dao = new CompraDAO(this.em);
        return dao.salvar(c);
    }
        public Compra buscaPorId(Integer id){
        CompraDAO dao = new CompraDAO(this.em);
        return dao.buscaPorId(id);
    }
        public Collection<Compra> buscaTodosCompras(){
        CompraDAO dao = new CompraDAO(this.em);
        Collection<Compra> c = dao.buscaTodosCompras();
        return c;      
    }
    
        public void remover(Integer id){
        CompraDAO dao = new CompraDAO(this.em);
        dao.remover(id);
    }
}
